package com.cabinet;

import javax.swing.*;
import java.util.ArrayList;
import java.util.List;

/**
 * Created by IntelliJ IDEA.
 * User: denny
 * Date: 9/11/13
 * Time: 12:00 PM
 * To change this template use File | Settings | File Templates.
 */
public class Device {
  public static final int LAST_STUD = 15;
  public static final int DEVICE1 = 16;
  public static final int DEVICE2 = 17;
  public static final int DEVICE3 = 18;
  public static final int DEVICE4 = 19;
  public static final int TEACHER = 20;

  long id;
  String name;
  String shortName;

  public Device(long id, String name, String shortName) {
    this.id = id;
    this.name = name;
    this.shortName = shortName;
  }

  public long getId() {
    return id;
  }

  public String getName() {
    return name;
  }

  public static boolean isStudent(long deviceId){
    return deviceId <= LAST_STUD;
  }
  public static boolean hasSelfTest(long deviceId){
    return isStudent(deviceId);
  }

  public static boolean isAudioDevice(long deviceId){
    return deviceId >= DEVICE1 && deviceId <= DEVICE4;
  }

  public static int audioDevNumber(long deviceId){
    if( isAudioDevice(deviceId) ){
      return (int)deviceId - DEVICE1 + 1;
    }
    throw new IllegalArgumentException("devId="+deviceId);
  }

  public static List<Device> all(){
    List<Device> list = new ArrayList<>();
    for( int i=1; i<=16; i++ ){
      list.add(new Device(i-1, "робоче місце "+i, ""+i));
    }
    list.add(new Device(DEVICE1,"Аудіо пристрій 1","A1"));
    list.add(new Device(DEVICE2,"Аудіо пристрій 2","A2"));
    list.add(new Device(DEVICE3,"Аудіо пристрій 3","A3"));
    list.add(new Device(DEVICE4,"Аудіо пристрій 4","A4"));
    list.add(new Device(TEACHER,"Вчитель","Вч"));
    return list;
  }

  public String getShortName() {
    return shortName;
  }
}
